import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '项目',
    align: 'center',
    sorter: true,
    dataIndex: 'projectId_dictText'
  },
  {
    title: '批次',
    align: 'center',
    sorter: true,
    dataIndex: 'batchId_dictText'
  },
  {
    title: '计划名称',
    align: 'left',
    sorter: true,
    dataIndex: 'planName'
  },
  {
    title: '计划开始时间',
    align: 'center',
    sorter: true,
    dataIndex: 'planStartTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '计划结束时间',
    align: 'center',
    sorter: true,
    dataIndex: 'planEndTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '参与人员',
    align: 'center',
    sorter: true,
    dataIndex: 'attendUsers_dictText'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "项目",
    field: "projectId",
    component: 'JSearchSelect',
    componentProps: {
      dict:"tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "批次",
    field: "batchId",
    component: 'JSearchSelect',
    componentProps: {
      dict:"tm_project_batch,batch_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "父级节点",
    field: "pid",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "计划名称",
    field: "planName",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "计划开始时间",
    field: "planStartTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "计划结束时间",
    field: "planEndTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目',
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
       dict: "tm_project,project_name,id"
    },
    dynamicRules: ({ model, schema }) => {
      return [
              { required: true, message: '请输入项目!' },
             ];
    },
  },
  {
    label: '批次',
    field: 'batchId',
    component: 'JSearchSelect',
    componentProps:{
       dict: "tm_project_batch,batch_name,id"
    },
    dynamicRules: ({ model, schema }) => {
      return [
              { required: true, message: '请输入批次!' },
             ];
    },
  },
  {
    label: '父级节点',
    field: 'pid',
    component: 'JTreeSelect',
    componentProps: {
      dict: "tm_crowd_test_plan,plan_name,id",
      pidField: "pid",
      pidValue: "0",
      hasChildField: "has_child",
    },
  },
  {
    label: '计划名称',
    field: 'planName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
              { required: true, message: '请输入计划名称!' },
             ];
    },
  },
  {
    label: '计划开始时间',
    field: 'planStartTime',
    component: 'DatePicker',
    dynamicRules: ({ model, schema }) => {
      return [
              { required: true, message: '请输入计划开始时间!' },
             ];
    },
  },
  {
    label: '计划结束时间',
    field: 'planEndTime',
    component: 'DatePicker',
    dynamicRules: ({ model, schema }) => {
      return [
              { required: true, message: '请输入计划结束时间!' },
             ];
    },
  },
  {
    label: '参与人员',
    field: 'attendUsers',
    component: 'JSearchSelect',
    componentProps:{
       dict: "sys_user,realname,username"
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目',order: 0,view: 'sel_search', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  batchId: {title: '批次',order: 1,view: 'sel_search', type: 'string',dictTable: "tm_project_batch", dictCode: 'id', dictText: 'batch_name',},
  planName: {title: '计划名称',order: 3,view: 'text', type: 'string',},
  planStartTime: {title: '计划开始时间',order: 4,view: 'date', type: 'string',},
  planEndTime: {title: '计划结束时间',order: 5,view: 'date', type: 'string',},
  attendUsers: {title: '参与人员',order: 6,view: 'sel_search', type: 'string',dictTable: "sys_user", dictCode: 'username', dictText: 'realname',},
};
